package com.maple.common.utils.agreements;
import com.maple.common.utils.Tools;
import java.math.BigDecimal;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class B3AgreementUtil {
    /**
     * 输出结果
     * **/
    public static String getData(String matcherString){
        byte[]data=Tools.parseHexStr2Byte(matcherString);
        if (data.length!=8){
            return "";
        }
        StringBuilder builder=new StringBuilder();
        for (int i = data.length-2; i >=0 ; i--) {
//            matcherString.substring(i-2,i);
            builder.append((char) data[i]);
        }
        String res=builder.toString();
        BigDecimal decimal=new BigDecimal(res.trim());
        System.out.println(decimal.toString());
        return decimal.toString();


    }
    /**
     * 截取字符串
     * */
    public static void testRegexp(String s,CallBackWeight callBackWeight) {
        if (s != null && !"".equals(s)) {
            String regex = "[0-9a-fA-F]{14}3D";
            Pattern pattern = Pattern.compile(regex);
            Matcher matcher = pattern.matcher(s);
            while (matcher.find()) {
                String matcherString = matcher.group();
                System.out.println(matcherString);
                String w=getData(matcherString);
                callBackWeight.succeed(w);
//                if (checkData(matcherString)) {
//                    System.out.println("输出重量：" + readWeight(matcherString) + "kg");
//                }
            }
        }
    }
}
